package cn.iocoder.yudao.module.stock.dal.mysql.stock;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.stock.dal.dataobject.stock.StockDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.stock.controller.admin.stock.vo.*;

/**
 * 商品库存 Mapper
 *
 * @author 徐煜东
 */
@Mapper
public interface StockMapper extends BaseMapperX<StockDO> {

    default PageResult<StockDO> selectPage(StockPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StockDO>()
                .eqIfPresent(StockDO::getProductId, reqVO.getProductId())
                .eqIfPresent(StockDO::getAvailableQuantity, reqVO.getAvailableQuantity())
                .eqIfPresent(StockDO::getLockedQuantity, reqVO.getLockedQuantity())
                .betweenIfPresent(StockDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StockDO::getId));
    }

}
